package com.findtech.threePomelos.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.findtech.threePomelos.R;
import com.findtech.threePomelos.adapter.AdapterItemDecoration;
import com.findtech.threePomelos.adapter.MyDeviceAdapter;
import com.findtech.threePomelos.base.MyActionBarActivity;
import com.findtech.threePomelos.base.MyApplication;
import com.findtech.threePomelos.entity.BabyInfoEntity;
import com.findtech.threePomelos.utils.RequestUtils;

/**
 * Created by zhi.zhang on 3/19/16.
 */
public class MyDeviceActivity extends MyActionBarActivity implements RequestUtils.MyItemClickListener {
    RecyclerView mRecyclerView;
    MyDeviceAdapter mAdapter;
    BabyInfoEntity babyInfoEntity = BabyInfoEntity.getInstance();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_device_info);
        MyApplication.getInstance().addActivity(this);
        setToolbar(getResources().getString(R.string.text_activity_title_device), true);
        mAdapter = new MyDeviceAdapter(this);
        mRecyclerView = (RecyclerView) findViewById(R.id.app_device_recyclerview);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.addItemDecoration(new AdapterItemDecoration(this));
        mRecyclerView.setAdapter(mAdapter);
        mAdapter.setOnItemClickListener(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mAdapter.setIsBind(babyInfoEntity.getIsBind());
        mAdapter.notifyDataSetChanged();
    }

    @Override
    public void onItemClick(View view, int position) {
        startActivity(new Intent(this, MyDeviceOperateActivity.class));
    }
}
